package top.kaoshanji.p1ch04a;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.util.Locale;
import java.util.ResourceBundle;

/**
 * 代码清单 p1ch04a-08：资料包的查找过程和基本的使用方式
 * author kaoshanji
 * ^_^
 * create time 2025/1/15 16:53
 */
public class ResourceBundleExample01 {

    private static final Logger logger = LogManager.getLogger(ResourceBundleExample01.class);

    public static void main(String[] args) {
        logger.info("...代码清单 p1ch04a-08：资料包的查找过程和基本的使用方式...");

        // 基于Java类
        String baseName = "top.kaoshanji.p1ch04a.support.Messages";
        ResourceBundle bundleEn = ResourceBundle.getBundle(baseName, Locale.US);
        logger.info("...bundleEn:{}...", bundleEn.getString("GREETING"));

        // 基于属性文件
        ResourceBundle bundleCn = ResourceBundle.getBundle("p1ch04a08/Messages", Locale.CHINA);
        logger.info("...bundleCn:{}...", bundleCn.getString("THANK_YOU"));

    }

}
